package licode.unisop.platform.client.feign;

import licode.unisop.provider.info.*;
import licode.unisop.provider.vo.*;
import licode.unisop.unilite.result.UniResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @author licode
 */
@FeignClient(name = "${uni-sop.platform.service:uni-platform-service}", url = "${uni-sop.platform.host:}")
public interface PlatformQueryApiFeign {
    @PostMapping("/plat-api/v1/internal/platform/query/lookup")
    UniResult<SiPlatform> findPlatform(@RequestBody SiPlatIdFind findInfo);

    /**
     * 获取用户、角色、客户等资源信息
     * @param idFind 领域和资源ID
     * @return 用户资源
     */
    @PostMapping("/plat-api/v1/internal/platform/asset/query/info")
    UniResult<SiAssetEntry> findAsset(@RequestBody SiAssetId idFind);

    @PostMapping("/plat-api/v1/internal/platform/asset/query/brief-info")
    UniResult<SiAssetBrief> lookupAssetBrief(@RequestBody SiAssetLookupIn lookupIn);

    @PostMapping("/plat-api/v1/internal/platform/asset/query/sub-count")
    UniResult<Long> getSubAssetCount(@RequestBody SiAssetLookupIn lookupIn);

    /**
     * 根据ID获取其关联的其它资源
     * @param idFind 领域和资源ID
     * @return 资源ID信息
     */
    @PostMapping("/plat-api/v1/internal/platform/asset/query/asset-id/keys")
    UniResult<List<SiAssetKey>> findAssetKeys(@RequestBody SiAssetId idFind);

    /**
     * 获取平台资源信息
     * @param plInfo 平台ID查询条件
     * @return 平台资源信息
     */
    @PostMapping("/plat-api/v1/internal/platform/asset/query/platform-assets/info")
    UniResult<SiAssetInfo> getPlatformAssets(@RequestBody SiPlatIdFind plInfo);

    @PostMapping("/plat-api/v1/internal/platform/asset/query/lookup-auth-asset/by-code")
    UniResult<SiAssetBrief> lookupAuthAssetByCode(@RequestBody SiAssetCodeLookupIn req);

    @PostMapping("/plat-api/v1/internal/platform/asset/query/lookup-asset/by-code")
    UniResult<SiAssetBrief> lookupAssetByCode(@RequestBody SiLookupAssetByCodeIn req);

    @PostMapping("/plat-api/v1/internal/platform/asset/query/asset-list/by-code")
    UniResult<List<SiAssetBrief>> queryAssetsByCode(@RequestBody SiAssetCodeQueryIn req);

    /**
     * 获取用户资源信息
     * @param userInfo 用户ID查询条件
     * @return 平台资源信息
     */
    @PostMapping("/plat-api/v1/internal/platform/asset/query/user-assets/info")
    UniResult<SiAssetHold> getUserAssets(@RequestBody SiHoldInfo userInfo);

    /**
     * 获取资源关联的资源信息
     * @param holdInfo 用户ID查询条件
     * @return 平台资源信息
     */
    @PostMapping("/plat-api/v1/internal/platform/asset/query/hold-assets/info")
    UniResult<SiAssetHold> getHoldAssets(@RequestBody SiHoldInfo holdInfo);

    /**
     * 分页查找用户信息
     * @param req 查找条件
     * @return 用户信息
     */
    @PostMapping("/plat-api/v1/internal/platform/query/page")
    UniResult<SiPageResult<SiPlatform>> findPage(@RequestBody PlatPageInfo req);

    @PostMapping("/plat-api/v1/internal/platform/auth/query/page")
    UniResult<SiPageResult<String>> findAuthPlatformPage(@RequestBody AuthPlatPageInfo req);

    @PostMapping("/plat-api/v1/internal/platform/asset/query/page")
    UniResult<SiPageResult<SiAssetBrief>> findAssetPage(@RequestBody AssetPageInfo req);

    @PostMapping("/plat-api/v1/internal/platform/asset/query/list")
    UniResult<List<SiAssetBrief>> findAssetList(@RequestBody AssetListInfo req);

    @PostMapping("/plat-api/v1/internal/platform/asset/query/hold-ref-asset/page")
    UniResult<SiPageResult<SiAssetRelation>> findHoldRelAssetPage(@RequestBody HoldAssetPageInfo req);

    @PostMapping("/plat-api/v1/internal/platform/asset/query/asset-ref-hold/page")
    UniResult<SiPageResult<SiAssetRelation>> findAssetRelHoldPage(@RequestBody AssetHoldPageInfo req);

    @PostMapping("/plat-api/v1/internal/platform/asset/query/hold-asset/page")
    UniResult<SiPageResult<SiAssetBrief>> findHoldAssetPage(@RequestBody HoldAssetPageInfo req);

    @PostMapping("/plat-api/v1/internal/platform/asset/query/asset-hold/page")
    UniResult<SiPageResult<SiAssetBrief>> findAssetHoldPage(@RequestBody AssetHoldPageInfo req);
}